<?php
class classDB{
    public function open($host=null, $user_name=null, $psswd=null, $DB=null){
        if($host==null)     $host       = _DB_HOST_;
        if($user_name==null)$user_name  = _DB_USER_;
        if($psswd==null)    $psswd      = _DB_PSSWD_;
        if($DB==null)       $DB         = _DB_NAME_;

        $spojeni = @mysql_connect($host, $user_name, $psswd);
        if(!$spojeni)
            return 0; //missing server connection
        else {
            $result = mysql_select_db($DB);

            if ($result){  //connected
                $this->updateCharSet('utf8');
                return 1;
            }
        }
        
        return 0;
    }

    public function close(){
        mysql_close();
    }

    private function updateCharSet($csCharSet){
        mysql_query('set names '.$csCharSet);
    }
}
?>